from time import sleep,ctime
import logging
import threading
logging.basicConfig(level=logging.INFO)
loops = [3,4,5]
def loop(nloop,nsec):
    logging.info('start loop'+str(nloop)+' at '+ctime())
    sleep(nsec)
    logging.info('end loop' + str(nloop) + ' at ' + ctime())

def main():
    logging.info('start all loop'  + ctime())
    nloops=range(len(loops))
    threads = []
    for i in nloops:
        t = threading.Thread(target=loop,args=(i,loops[i]))
        threads.append(t)
    for i in nloops:
        threads[i].start()
    for i in nloops:  #类似于加锁，等线程结束，不结束则阻塞，执行完毕线程才解除阻塞
        threads[i].join()
    logging.info('end al loop'  + ctime())

if __name__ == '__main__':
    main()